{% extends 'generic/object.html' %}
{% load i18n %}
{% load helpers %}
{% load render_table from django_tables2 %}

{% block title %}{% trans "User" %} {{ object.username }}{% endblock %}

{% block subtitle %}{% endblock %}

{% block content %}
  <div class="row mb-3">
    <div class="col-md-6">
      <div class="card">
        <h2 class="card-header">{% trans "User" %}</h2>
        <table class="table table-hover attr-table">
          <tr>
            <th scope="row">{% trans "Username" %}</th>
            <td>{{ object.username }}</td>
          </tr>
          <tr>
            <th scope="row">{% trans "Full Name" %}</th>
            <td>{{ object.get_full_name|placeholder }}</td>
          </tr>
          <tr>
            <th scope="row">{% trans "Email" %}</th>
            <td>{{ object.email|placeholder }}</td>
          </tr>
          <tr>
            <th scope="row">{% trans "Account Created" %}</th>
            <td>{{ object.date_joined|isodate }}</td>
          </tr>
          <tr>
            <th scope="row">{% trans "Last Login" %}</th>
            <td>{{ object.last_login|isodatetime:"minutes"|placeholder }}</td>
          </tr>
          <tr>
            <th scope="row">{% trans "Active" %}</th>
            <td>{% checkmark object.is_active %}</td>
          </tr>
          <tr>
            <th scope="row">{% trans "Staff" %}</th>
            <td>{% checkmark object.is_staff %}</td>
          </tr>
          <tr>
            <th scope="row">{% trans "Superuser" %}</th>
            <td>{% checkmark object.is_superuser %}</td>
          </tr>
        </table>
      </div>
    </div>
    <div class="col-md-6">
      <div class="card">
        <h2 class="card-header">{% trans "Assigned Groups" %}</h2>
        <div class="list-group list-group-flush">
          {% for group in object.groups.all %}
            <a href="{% url 'users:group' pk=group.pk %}" class="list-group-item list-group-item-action">{{ group }}</a>
          {% empty %}
            <div class="list-group-item text-muted">{% trans "None" %}</div>
          {% endfor %}
        </div>
      </div>
      <div class="card">
        <h2 class="card-header">{% trans "Assigned Permissions" %}</h2>
        <div class="list-group list-group-flush">
          {% for perm in object.object_permissions.all %}
            <a href="{% url 'users:objectpermission' pk=perm.pk %}" class="list-group-item list-group-item-action">{{ perm }}</a>
          {% empty %}
            <div class="list-group-item text-muted">{% trans "None" %}</div>
          {% endfor %}
        </div>
      </div>
    </div>
  </div>
  {% if perms.core.view_objectchange %}
    <div class="row">
      <div class="col-md-12">
        <div class="card">
          <h2 class="text-center">{% trans "Recent Activity" %}</h2>
          <div class="card-body table-responsive">
            {% render_table changelog_table 'inc/table.html' %}
          </div>
        </div>
      </div>
    </div>
  {% endif %}
{% endblock %}
